<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>

  function isPrime(num){
  //  1、获取num的平方根
    var temp = parseInt(Math.sqrt(num)) //parseInt():转化为整数，Math.sqrt()获取平方根

  //  2、循环判断
    for(var i = 2;i<=temp;i++){
      if(num % i == 0){
        return false
      }
    }

    return true

  }

</script>
</body>
</html>